package tests;

import input.InputManager;
import data.Vector2;
import main.Core;
import model.TextSprite;
import scene.BaseScene;

/**
 * Testa as classes de entrada.
 * @author Ygor
 *
 */
public class InputTest extends BaseScene {


	final TextSprite confirm;
	final TextSprite cancel;
	final TextSprite up;
	final TextSprite down;
	final TextSprite left;
	final TextSprite right;
	
	final TextSprite x;
	final TextSprite y;
	final TextSprite leftButton;
	final TextSprite rightButton;
	final TextSprite middleButton;
	
	public InputTest(Core core) {
		super(core);
		
		int keyboardSpritesX = 410;
		int keyboardSpritesY = 280;
		
		int mouseSpritesX = 200;
		int mouseSpritesY = 280;
		
		int spacing = 20;
		
		x = new TextSprite("basic", "x", new Vector2(mouseSpritesX, mouseSpritesY), Vector2.zero(), this, core);
		y = new TextSprite("basic", "y", new Vector2(mouseSpritesX, mouseSpritesY + spacing), Vector2.zero(), this, core);
		leftButton = new TextSprite("basic", "LeftButton", new Vector2(mouseSpritesX, mouseSpritesY + spacing * 3), Vector2.zero(), this, core);
		rightButton = new TextSprite("basic", "RightButton", new Vector2(mouseSpritesX, mouseSpritesY + spacing * 4), Vector2.zero(), this, core);
		middleButton = new TextSprite("basic", "MiddleButton", new Vector2(mouseSpritesX, mouseSpritesY + spacing * 5), Vector2.zero(), this, core);
		
		
		confirm = new TextSprite("basic", "Confirm", new Vector2(keyboardSpritesX, keyboardSpritesY), Vector2.zero(), this, core);
		cancel = new TextSprite("basic", "Cancel", new Vector2(keyboardSpritesX, keyboardSpritesY + spacing), Vector2.zero(), this, core);
		up = new TextSprite("basic", "Up", new Vector2(keyboardSpritesX, keyboardSpritesY + spacing * 3), Vector2.zero(), this, core);
		down = new TextSprite("basic", "Down", new Vector2(keyboardSpritesX, keyboardSpritesY + spacing * 4), Vector2.zero(), this, core);
		left = new TextSprite("basic", "Left", new Vector2(keyboardSpritesX, keyboardSpritesY + spacing * 5), Vector2.zero(), this, core);
		right = new TextSprite("basic", "Right", new Vector2(keyboardSpritesX, keyboardSpritesY + spacing * 6), Vector2.zero(), this, core);
	}

	@Override
	public void update(float elapsedTime) {
		super.update(elapsedTime);
		
		if (InputManager.keyboard.getConfirm().isPressed()) {
			confirm.setText("HELD");
		}else {
			confirm.setText("Confirm");
		}
		if (InputManager.keyboard.getCancel().isPressed()) {
			cancel.setText("HELD");
		}else {
			cancel.setText("Cancel");
		}
		
		if (InputManager.keyboard.getUp().isPressed()) {
			up.setText("HELD");
		}else {
			up.setText("up");
		}
		if (InputManager.keyboard.getDown().isPressed()) {
			down.setText("HELD");
		}else {
			down.setText("down");
		}
		if (InputManager.keyboard.getLeft().isPressed()) {
			left.setText("HELD");
		}else {
			left.setText("left");
		}
		if (InputManager.keyboard.getRight().isPressed()) {
			right.setText("HELD");
		}else {
			right.setText("right");
		}
		
		if (InputManager.mouse.getLeftButton().isPressed()) {
			leftButton.setText("HELD");
		}else {
			leftButton.setText("left");
		}
		if (InputManager.mouse.getRightButton().isPressed()) {
			rightButton.setText("HELD");
		}else {
			rightButton.setText("right");
		}
		if (InputManager.mouse.getMiddleButton().isPressed()) {
			middleButton.setText("HELD");
		}else {
			middleButton.setText("middle");
		}
		
		x.setText(InputManager.mouse.getX() + "");
		y.setText(InputManager.mouse.getY() + "");
	}
}
